﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using IStrong.EC.Web.Controllers;
using IStrong.EC.WebApi.Results.Repository;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace IStrong.EC.WebApi.Results.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ChannelImportanceController : BaseController
    {
        /// <summary>
        /// 日志
        /// </summary>
        private readonly ILogger<ChannelfollowingController> _logger;

        /// <summary>
        /// 配置
        /// </summary>
        private readonly IConfiguration _config;


        private readonly ChannelimportanceRepository _channelimportanceRepository;

        /// <summary>
        /// 注入服务 
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="logger"></param>
        /// <param name="config"></param>
        public ChannelImportanceController(ILogger<ChannelfollowingController> logger, IConfiguration config, ChannelimportanceRepository channelimportanceRepository)
        {
            _logger = logger;
            _config = config;
            _channelimportanceRepository = channelimportanceRepository;
        }

        [HttpGet]
        public JsonResult Get(int channelid)
        {
            try
            {
                var data = _channelimportanceRepository.GetImportanceById(new { channelid });
                return Json(data);
            }
            catch (Exception ex)
            {
                return Json(ex);
            }
        }
    }
}